/*
  将下面异步代码使用 Promise 的方法改进
  尽量用看上去像同步代码的方式
  setTimeout(function () {
    var a = 'hello'
    setTimeout(function () {
      var b = 'lagou'
      setTimeout(function () {
        var c = 'I ♥ U'
        console.log(a + b +c)
      }, 10)
    }, 10)
  }, 10)
*/

// 方法一 使用 async await语法糖实现
async function showPromise() {
  let a = await Promise.resolve('hello')
  let b = await Promise.resolve('lagou')
  let c = await Promise.resolve('I 💗 U')
  console.log(a + b + c)
}
showPromise()

// 方法二
let showPromise = new Promise(resolve => {
  var a = 'hello'
  resolve(a)
}).then( resolve => {
  var b = 'lagou'
  return resolve + b
}).then ( resolve => {
  var c = 'I ❤ U';
  return resolve + c
})
showPromise.then(msg => {
  console.log(msg)
})